function foo(x) {
    console.log(this.a, x);
}
const obj = {
    a: 1
}
// foo.call(obj, 2)



Function.prototype.myCall = function (...args) {
    // call 将foo引用到obj上
    // 让obj调用foo
    // 移除obj上的foo
    const context = args[0]
    const arg = args.slice(1)  // [2,3,4]
    context.fn = this
    const res = context.fn(...arg)
    delete context.fn
    return res
}

foo.myCall(obj, 2, 3, 4)